//
<<<<<<< HEAD:cxx/algorithm/src/climbStairs.cc
// Created by liushuai on 2020/3/30.
//
#include "climbStairs.h"
int climbStairs(unsigned int n) {
  int lower = 2;
  int upper = 3;
  int result = 0;
  if (n == 0)
    result = 0;
  else if (n > 0 && n <= 3)
    result = n;
  else {
    while (n > 3) {
      result = upper + lower;
      lower = upper;
      upper = result;
      n--;
    }
  }
  return result;
}
=======
// Created by liushuai on 12/19/19.
//
#include <unordered_map>

std::unordered_map<int, int> cache;

int climbStairs(int n) {
  if (cache.count(n))
    return cache.at(n);
  else {
    if (n < 3)
      return n;
    else {
      int result = 0;
      result = climbStairs(n - 1) + climbStairs(n - 2);
      cache[n] = result;
      return result;
    }
  }
}

int climbStairs(int n, int m) {
  if (n >= m)
    return 0;
  else if (n == m)
    return 1;
  else
    return climbStairs(n + 1, m) + climbStairs(n + 2, m);
}
>>>>>>> dev:cxx/algorithm/common/src/climbStairs.cc
